home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-02 / prodpack.zip / DB4PPSRC.EXE / _INTINBO.PRG < prev    next >
Text File  |  1993-05-04  |  3KB  |  120 lines

  1. FUNCTION _IntInBox
  2. PARAMETERS pn_row, pn_col, pc_prompt, pn_default, pn_low, pn_high
  3. *---------------------------------------------------------------------
  4. * NAME
  5. *   _IntInBox - Get an integer value in a box
  6. *
  7. * DESCRIPTION
  8. *     This routine implements the fill-in popup to get an integer
  9. *     value from the user.  The box dimensions are determined on the
  10. *     fly depending upon the prompt length and the maximum allowable
  11. *     value. The height of the box is assumed to be 3.   If an error
  12. *     is encountered during processing, that error is displayed with a
  13. *     beep and we return -1 with the ivalue remaining unchanged.  If the
  14. *     user hits ESCAPE key then also -1 is returned (without changing
  15. *     the original ivalue) and the caller should take appropriate action
  16. *     (may be no action).
  17. *
  18. * SYNOPSIS
  19. *
  20. * PARAMETERS
  21. *   pn_row      = Top row position
  22. *   pn_col      = Left column position
  23. *   pc_prompt   = Prompt message inside of the box
  24. *   pn_default  = Starting value
  25. *   pn_low      = Samllest permissible number
  26. *   pn_high     = Largest permissible number
  27. *
  28. * LIMITATIONS
  29. *
  30. * DEPENDENCIES
  31. *
  32. *---------------------------------------------------------------------
  33.   PRIVATE ll_deli, ln_val, lc_pict, ln_inboxw, ln_rtn, lc_window, ;
  34.           ln_getcol
  35.  
  36.   ll_deli = SET("DELIMITER") = "ON"
  37.   SET DELIMITER OFF
  38.  
  39.   lc_window = WINDOW()
  40.  
  41.   IF pn_high > 9999
  42.     lc_pict = "#####"
  43.   ELSE
  44.     IF pn_high > 999
  45.       lc_pict = "####"
  46.     ELSE
  47.       IF pn_high > 99
  48.         lc_pict = "###"
  49.       ELSE
  50.         IF pn_high > 9
  51.           lc_pict = "##"
  52.         ELSE
  53.           lc_pict = "#"
  54.         ENDIF
  55.       ENDIF
  56.     ENDIF
  57.   ENDIF
  58.   ln_pict = LEN( lc_pict )
  59.  
  60.   *-- Inside width is length of prompt plus one space at front and
  61.   *-- two spaces after prompt plus the width of the picture template
  62.   ln_inboxw = LEN( pc_prompt ) + 3 + ln_pict
  63.  
  64.   DEFINE WINDOW IntInBox FROM pn_row, pn_col ;
  65.                          TO pn_row+2, pn_col+ln_inboxw DOUBLE
  66.   ACTIVATE WINDOW IntInBox
  67.   @ 0,0 SAY [ ] + pc_prompt + [  ]
  68.  
  69.   ln_val = pn_default
  70.  
  71.   ln_rtn = 0
  72.   ln_getcol = ln_inboxw - ln_pict - 1
  73.  
  74.   DO WHILE .T.
  75.     @ 0, ln_getcol GET ln_val PICTURE (lc_pict)
  76.     DO _Read_It
  77.     ln_lastkey = LASTKEY()
  78.     DO CASE
  79.       CASE ln_lastkey = 27
  80.         ln_val = pn_default
  81.         ln_rtn = -1
  82.         EXIT
  83.       CASE ln_lastkey = 5               && Up arrow
  84.         ln_val = ln_val + 1
  85.         IF ln_val > pn_high
  86.           ln_val = pn_low
  87.         ENDIF
  88.       CASE ln_lastkey = 24              && Down arrow
  89.         ln_val = ln_val -1
  90.         IF ln_val < pn_low
  91.           ln_val = pn_high
  92.         ENDIF
  93.       OTHERWISE
  94.         IF ln_val >= pn_low .AND. ln_val <= pn_high
  95.           EXIT
  96.         ELSE
  97.           ?? CHR(7)
  98.         ENDIF
  99.     ENDCASE
  100.   ENDDO
  101.  
  102.   IF ln_rtn = 0
  103.     pn_default = ln_val
  104.   ENDIF
  105.  
  106.   RELEASE WINDOW IntInBox
  107.  
  108.   IF ll_deli
  109.     SET DELIMITER ON
  110.   ENDIF
  111.   SET CURSOR ON
  112.  
  113.   IF .NOT. ISBLANK( lc_window )
  114.     ACTIVATE WINDOW &lc_window
  115.   ENDIF
  116.  
  117. RETURN( ln_rtn )
  118. *-- EOF:  _IntInBox( pn_row, pn_col, pc_prompt, pn_default, pn_low, pn_high )
  119.  
  120.